package com.xgkj.diyiketang.task;

import com.alibaba.fastjson.JSONObject;
import com.xgkj.diyiketang.http.CouponHttpRequest;
import com.xgkj.diyiketang.http.CouponHttpResponse;
import com.xgkj.diyiketang.http.engine.CouponHttpBaseTask;
import com.xgkj.diyiketang.http.engine.TaskResultCode;

/**
 * Created by windo on 17/1/3.
 */

public class CreateYuanwangTask extends CouponHttpBaseTask{
    private String desireTitle;
    private String desireContent;
    private String timeStart;
    private String timeEnd;
    private String count;
    private String flowerCount;
    private String witnessId;
    public CreateYuanwangTask(String title,String desc,String starttime,String endtime,String count,String flowercount,String witnessId) {
        super();
        desireTitle = title;
        desireContent = desc;
        timeStart = starttime;
        timeEnd = endtime;
        this.count = count;
        this.flowerCount = flowercount;
        this.witnessId = witnessId;
    }

    @Override
    protected void processResponseData(CouponHttpResponse response) {
        notifyTaskCompleted(TaskResultCode.SUCCESS,null);
    }

    @Override
    protected void prepareRequest() {
        super.prepareRequest();
        if (mPhase == TASK_PHASE_INIT){
            CouponHttpRequest request = new CouponHttpRequest();
            request.setApiNo(ApiNo.CREATE_YUANWANG);
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("desireTitle",desireTitle);
            jsonObject.put("desireContent",desireContent);
            jsonObject.put("timeStart",timeStart);
            jsonObject.put("timeEnd",timeEnd);
            jsonObject.put("count",count);
            jsonObject.put("flowerCount",flowerCount);
            jsonObject.put("witnessId",witnessId);
            request.setData(jsonObject.toString());
            addRequest(request);
        }
    }
}
